package jlib.component.tool.catchers {
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.geom.Point;
	import flash.geom.Rectangle;	

	/**
	 * 사용하지마세요.
	 * target을 잡아내는 클래스 .. 잡아내는 방법은 여러가지를 지원
	 * 정리 요망... 리팩해야됨 .
	 * @author �����
	 */
	public class DetailCatcher {
		
		private var startRightPoint:Point;
		private var bottomLeftPoint:Point;
		private var startPoint:Point;
		private var movePoint:Point;
		private var canvas:DisplayObjectContainer;
		private var areaRect:Rectangle;
		
		private var contains:Array;
		
		public function DetailCatcher(): void
		{
			throw new Error("미구현된 클래스");
			startRightPoint = new Point(); // hitPoint
			bottomLeftPoint = new Point();
		}
		
		/// 안쓰는거 - -;;
		// hitPoint 로 잡아 내기 -_-;; 느리다..
		private function catchTarget(): void
		{
			startRightPoint.x = startPoint.x+movePoint.x;
			startRightPoint.y = startPoint.y;
			bottomLeftPoint.x = startPoint.x;
			bottomLeftPoint.y = startPoint.y+movePoint.y;
			
			pushTarget(startPoint);
			pushTarget(movePoint);
			pushTarget(startRightPoint);
			pushTarget(bottomLeftPoint);
		}
		
		/*
		// drawn point로 잡아내기.. 느리다 ..
		protected function isIntersection( element:ISVGElement ): Boolean 
		{
			var stackArray:Array = element.getDrawnPoints();
			var returnBool:Boolean = false;
			var stackRect:Rectangle = new Rectangle(areaRect.x-canvas.x, areaRect.y-canvas.y, areaRect.width, areaRect.height);
			
			for( var i:int = 0 ; i < stackArray.length ; i++ ){
				if(stackRect.containsPoint(stackArray[i])){
				 	return true;
				 }
			}
			return returnBool;
		}*/
		
		private function pushTarget( point:Point ): void
		{
			var catchedObject:DisplayObject; 
			
			for( var j:int = 0 ;  j < canvas.numChildren ; j++){
				if(canvas.getChildAt(j).hitTestPoint(point.x, point.y, true)) catchedObject = canvas.getChildAt(j);
			}
			
			if(!catchedObject) return void; 
			
			if( contains == null || contains.length == 0 && catchedObject ){
				contains =new Array();
				contains.push( catchedObject );
			}else{
				for( var d:int = 0 ; d < contains.length ; d++){
					if( catchedObject != contains[d] && catchedObject != null) contains.push( catchedObject );
				}
			}
		}
		
		public function setContain(container:* , contains:Array ): void
		{
			this.canvas = container.canvas as DisplayObjectContainer;
			this.contains = contains;
		}
	}//c
}//p
